// 第一题
// 考察this指向问题
var name = 'window';
var person1 = {
    name: 'person1',
    show1: function () { 
        console.log(this.name);
    },
    show2: () => console.log(this.name),
    show3: function() {
        return function() {
            console.log(this);
        }
    },
    show4: function() {
        return () => console.log(this.name);
    }
}

var person2 = { name: 'person2' };

// 知识点
// 1、箭头函数指向是在编译期间创建，在定义那一刻就已经确定，是上下文的this，不可以改变
// 2、普通定义的函数中this是在执行时候确定，可以改变this的指向

// this => person1
person1.show1();// 'person1'
// this => person1 => person2
person1.show1.call(person2);// 'person2'


// this => window
person1.show2();// 'window'
// 箭头函数this指向无法改变
person1.show2.call(person2);// ‘window’


// var fn = person1.show3() => this => window
person1.show3()();// window对象
// var fn = person1.show3() => this => person2
person1.show3().call(person2);// person2对象


// this => person1
person1.show4()(); // 'person1'
// var fn = person.show4() => person1
person1.show4().call(person2);// 'person1'
// this => person2
person1.show4.call(person2)();// 'person2'